<template>
  <scroll-view 
  enable-flex class="video_main"
  scroll-y   @scrolltolower="handleScrolltolower"
  >
  
  <view class="video_items"
   v-for="item in videowp" :key="item.id" @click="handleClick(item)">
      <image :src="item.img" mode="widthFix" />
  </view>
  </scroll-view>
</template>

<script>
export default {
    data(){
        return{
            videowp:[],
            hasMore:true
        }
    },
    props:{
        urlobj:Object
    },
    watch:{
        urlobj(){
            console.log(this.urlobj);
            this.videowp = [];
            this.getList();
        }
    },
    mounted(){
        this.getList();
    },
    methods:{
        getList(){
            this.request({
                url:this.urlobj.url,
                data:this.urlobj.params
            })
            .then(res=>{
                //console.log(res.res);
                if(res.res.videowp.length === 0){
                    this.hasMore = false;
                    uni.showToast({
                        title:"没有更多数据鸟",
                        icon:"none"
                    })
                    return;
                }
                this.videowp = [...this.videowp , ...res.res.videowp];
            })
        },
        handleScrolltolower(){
            if(this.hasMore){
            this.urlobj.params.skip += this.urlobj.params.limit;
            this.getList();
            }else{
                 uni.showToast({
                        title:"没有更多数据鸟",
                        icon:"none"
                    })
            }
        },
        handleClick(item){
            getApp().globalData.item = item;
            uni.navigateTo({
                url:"/pages/videoPlay/videoPlay"
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.video_main{
    height: calc( 100vh - 35px);
    display: flex;
    flex-wrap: wrap;
    .video_items{
        width: 33.33%;
        border: #fff solid 5rpx;
    }
}
</style>